{layout name="public/layout" /}
<!-- 内容主体区域 -->
<div class="site-block">
    <blockquote class="layui-elem-quote">
            <span class="layui-breadcrumb" lay-separator=">">
                <a href="">首页</a>
                <a><cite>设置配置</cite></a>
            </span>
    </blockquote>
    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane" action="" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">中文名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="cname" required="" lay-verify="required" placeholder="请输入中文名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">英文名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="ename" required="" lay-verify="required" placeholder="请输入英文名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">配置类型</label>
                    <div class="layui-input-inline">
                        <select name="c_type" lay-filter="aihao">
                            <option value=""></option>
                            <option selected="" value="1">单行文本框</option>
                            <option value="2">单选按钮</option>
                            <option value="3">复选框</option>
                            <option value="4">下拉框</option>
                            <option value="5">文本域</option>
                            <option value="6">附件</option>
                            <option value="7">开关按钮</option>
                        </select><div class="layui-unselect layui-form-select"><div class="layui-select-title"><input type="text" placeholder="请选择" value="阅读" readonly="" class="layui-input layui-unselect"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit" style=""><dd lay-value="" class="layui-select-tips">请选择</dd><dd lay-value="0" class="">写作</dd><dd lay-value="1" class="layui-this">阅读</dd><dd lay-value="2" class="">游戏</dd><dd lay-value="3" class="">音乐</dd><dd lay-value="4" class="">旅行</dd></dl></div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">默认值</label>
                    <div class="layui-input-block">
                        <input type="text" name="c_value" required="" lay-vertype="tips" placeholder="一般不超过200个字符" autocomplete="off" class="layui-textarea">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">可选值</label>
                    <div class="layui-input-block">
                        <input type="text" name="c_values" required="" lay-vertype="tips" placeholder="一般不超过200个字符" autocomplete="off" class="layui-textarea">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
</div>
<script>
    //Demo
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){

            $.ajax({
                url: "{:url('config/cadd')}",//POST给检测数据
                type: 'POST',
                data:data.field,
                dataType: 'json',

             }).done(function(res) {
                if(res.code==0){
                    //有错抖一抖效果
                    layer.msg(res.msg,function(){});
                }else{
                    layer.alert(res.msg,function(index){
                        layer.close(index);
                        window.location.href=res.url;

                    });
                }
            }).fail(function() {
                        //实现抖一抖效果
                        layer.msg('系统异常，请稍后再试',function(){})
                    });
            return false;
        });
    });
</script>